package org.example.transaction.controller;


import org.example.transaction.service.LogInfoService;
import org.example.transaction.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user3")
public class LoginController3 {


    @Autowired
    private UserInfoService userInfoService;

    @Autowired
    private LogInfoService logInfoService;


    @Transactional(propagation = Propagation.REQUIRED)
    @RequestMapping("/Login")
    public String login(String userName,String password){

        Integer n = userInfoService.insertUserInfo(userName,password);
        System.out.println("login影响的行数："+n);

        Integer result = logInfoService.insertLogInfo(userName,"登录操作");
        System.out.println("log影响的行数："+result);

        return "增加成功";
    }
}
